import os
import sys

# 添加项目根目录到Python路径，以便导入config_reader模块
current_dir = os.path.dirname(os.path.abspath(__file__))
project_root = os.path.dirname(os.path.dirname(current_dir))
sys.path.append(project_root)

from config_reader import get_openai_hk_api_key
from langchain_openai import ChatOpenAI
from langchain.schema import HumanMessage

# 从配置文件获取API密钥
api_key = get_openai_hk_api_key()

llm = ChatOpenAI(
    api_key=api_key,
    base_url="https://api.openai-hk.com/v1",
    model="gpt-3.5-turbo"  # 香港 OpenAI 网关
)

# 发送 Hello World 消息
response = llm.invoke([HumanMessage(content="Hello, world!")])
print(response.content)
